package org.dromara.company.controller;

import java.util.List;

import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.satoken.utils.LoginHelper;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.admin.domain.vo.TemplateMarketVo;
import org.dromara.admin.domain.bo.TemplateMarketBo;
import org.dromara.admin.service.ITemplateMarketService;
import org.dromara.common.mybatis.core.page.TableDataInfo;

/**
 * 公司端模板市场
 *
 * @author Lion Li
 * @date 2025-10-09
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/company/templateMarket")
public class TemplateMarketController extends BaseController {

    private final ITemplateMarketService templateMarketService;

    /**
     * 查询模板市场列表
     */
//    @SaCheckPermission("system:templateMarket:list")
    @GetMapping("/list")
    public TableDataInfo<TemplateMarketVo> list(TemplateMarketBo bo, PageQuery pageQuery) {
        Long userId = LoginHelper.getUserId();
        if (userId == null) {
            throw new ServiceException("请先登录！");
        }
        bo.setLoginUserId(userId);
        return templateMarketService.queryPageList(bo, pageQuery);
    }

    /**
     * 获取模板市场详细信息
     *
     * @param id 主键
     */
//    @SaCheckPermission("system:templateMarket:query")
    @GetMapping("/{id}")
    public R<TemplateMarketVo> getInfo(@NotNull(message = "主键不能为空")
                                       @PathVariable Long id) {
        return R.ok(templateMarketService.queryById(id));
    }
}
